package org.design.thread.two;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

/**
 * OrderService
 * 事件监听（ApplicationEventPublisher）
 * 适用场景：系统解耦，异步处理事件
 * 发布事件
 *
 * @author 樊温军
 * @date 2025/6/13 下午5:33
 */
@Service
public class OrderService {

    @Autowired
    private ApplicationEventPublisher eventPublisher;

    public void createOrder() {
        // 创建订单逻辑...
        eventPublisher.publishEvent(new OrderCreatedEvent(this, 123L));
    }
}

